<template>
  <div>

    <el-container>
      <SidebarMenu
        :default-active="activeMenu"
        @goToRoleManagement="goToRoleManagement"
        @goToMenuManagement="goToMenuManagement"
        @goToPermissionControl="goToPermissionControl"
        @goToSystemSetting="goToSystemSetting"
        @goToLogManagement="goToLogManagement"
        @goToFileManagement="goToFileManagement"
        @goToArticleManagement="goToArticleManagement"
        @goToUserInfoManagement="goToUserInfoManagement"
      />

      <el-container>
        <el-header>
          <Navbar title="角色管理" :avatar="currentAvatar" />

        </el-header>

        <el-main>
          <!-- 查询表单 -->
          <el-card class="query-card" shadow="never">
            <el-form :inline="true" :model="queryForm" @submit.prevent="searchRoles">
              <el-form-item label="角色名称">
                <el-input 
                  v-model="queryForm.roleName" 
                  placeholder="请输入角色名称" 
                  clearable
                  @keyup.enter="searchRoles"
                />
              </el-form-item>
              <el-form-item label="角色描述">
                <el-input 
                  v-model="queryForm.roleDescription" 
                  placeholder="请输入角色描述" 
                  clearable
                  @keyup.enter="searchRoles"
                />
              </el-form-item>
              <el-form-item label="角色状态">
                <el-select v-model="queryForm.status" placeholder="请选择状态" clearable>
                  <el-option label="启用" value="active" />
                  <el-option label="禁用" value="inactive" />
                </el-select>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="searchRoles" :loading="loading">
                  <el-icon><Search /></el-icon>
                  查询
                </el-button>
                <el-button @click="resetQueryForm">
                  <el-icon><Refresh /></el-icon>
                  重置
                </el-button>
                <el-button type="success" @click="showCreateDialog">
                  <el-icon><Plus /></el-icon>
                  新增角色
                </el-button>
              </el-form-item>
            </el-form>
          </el-card>

          <!-- 统计信息 -->
          <el-row :gutter="20" class="statistics-row">
            <el-col :span="6">
              <el-card class="statistics-card">
                <div class="statistics-item">
                  <div class="statistics-number">{{ statistics.totalRoles }}</div>
                  <div class="statistics-label">总角色数</div>
                </div>
              </el-card>
            </el-col>
            <el-col :span="6">
              <el-card class="statistics-card">
                <div class="statistics-item">
                  <div class="statistics-number">{{ statistics.activeRoles }}</div>
                  <div class="statistics-label">启用角色</div>
                </div>
              </el-card>
            </el-col>
            <el-col :span="6">
              <el-card class="statistics-card">
                <div class="statistics-item">
                  <div class="statistics-number">{{ statistics.totalUsers }}</div>
                  <div class="statistics-label">关联用户</div>
                </div>
              </el-card>
            </el-col>
            <el-col :span="6">
              <el-card class="statistics-card">
                <div class="statistics-item">
                  <div class="statistics-number">{{ statistics.totalPermissions }}</div>
                  <div class="statistics-label">权限总数</div>
                </div>
              </el-card>
            </el-col>
          </el-row>

          <!-- 角色表格 -->
          <el-card class="role-table-card">
            <template #header>
              <div class="card-header">
                <span>角色列表</span>
                <div class="header-actions">
                  <el-button type="warning" size="small" @click="batchDisable" :disabled="selectedRows.length === 0">
                    批量禁用
                  </el-button>
                  <el-button type="danger" size="small" @click="batchDelete" :disabled="selectedRows.length === 0">
                    批量删除
                  </el-button>
                </div>
              </div>
            </template>

            <el-table :data="roles" style="width: 100%" v-loading="loading" @selection-change="handleSelectionChange">
              <el-table-column type="selection" width="55" />
              <el-table-column prop="name" label="角色名称" width="150">
                <template #default="scope">
                  <div class="role-name">
                    <span v-if="scope.row.isSystem" class="system-badge">系统</span>
                    {{ scope.row.name }}
                  </div>
                </template>
              </el-table-column>
              <el-table-column prop="description" label="角色描述" min-width="200" />
              <el-table-column prop="status" label="状态" width="100">
                <template #default="scope">
                  <el-tag :type="scope.row.status === 'active' ? 'success' : 'danger'">
                    {{ scope.row.status === 'active' ? '启用' : '禁用' }}
                  </el-tag>
                </template>
              </el-table-column>
              <el-table-column prop="userCount" label="用户数" width="100" />
              <el-table-column prop="permissionCount" label="权限数" width="100" />
              <el-table-column prop="createTime" label="创建时间" width="160">
                <template #default="scope">
                  {{ formatDateTime(scope.row.createTime) }}
                </template>
              </el-table-column>
              <el-table-column prop="modifyTime" label="修改时间" width="160">
                <template #default="scope">
                  {{ formatDateTime(scope.row.modifyTime) }}
                </template>
              </el-table-column>
              <el-table-column label="操作" width="250" fixed="right">
                <template #default="scope">
                  <el-button type="text" size="small" @click="editRole(scope.row)">编辑</el-button>
                  <el-button type="text" size="small" @click="assignPermissions(scope.row)">分配权限</el-button>
                  <el-button type="text" size="small" @click="viewUsers(scope.row)">查看用户</el-button>
                  <el-button
                    type="text"
                    size="small"
                    @click="toggleStatus(scope.row)"
                    :disabled="scope.row.isSystem"
                  >
                    {{ scope.row.status === 'active' ? '禁用' : '启用' }}
                  </el-button>
                  <el-button
                    type="text"
                    size="small"
                    @click="deleteRole(scope.row)"
                    :disabled="scope.row.isSystem"
                  >
                    删除
                  </el-button>
                </template>
              </el-table-column>
            </el-table>

            <!-- 分页 -->
            <div class="pagination-container">
              <el-pagination
                :current-page="pagination.currentPage"
                :page-size="pagination.pageSize"
                :page-sizes="[10, 20, 50, 100]"
                :total="pagination.total"
                layout="total, sizes, prev, pager, next, jumper"
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
              />
            </div>
          </el-card>
        </el-main>
      </el-container>
    </el-container>

    <!-- 新增/编辑角色对话框 -->
    <el-dialog v-model="roleDialogVisible" :title="dialogTitle" width="600px">
      <el-form :model="roleForm" :rules="roleRules" ref="roleFormRef" label-width="100px">
        <el-form-item label="角色名称" prop="name">
          <el-input v-model="roleForm.name" placeholder="请输入角色名称" />
        </el-form-item>
        <el-form-item label="角色描述" prop="description">
          <el-input
            v-model="roleForm.description"
            type="textarea"
            :rows="3"
            placeholder="请输入角色描述"
          />
        </el-form-item>
        <el-form-item label="角色状态" prop="status">
          <el-radio-group v-model="roleForm.status">
            <el-radio label="active">启用</el-radio>
            <el-radio label="inactive">禁用</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="排序权重">
          <el-input-number v-model="roleForm.sortWeight" :min="0" :max="999" />
        </el-form-item>
      </el-form>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="roleDialogVisible = false">取消</el-button>
          <el-button type="primary" @click="saveRole">保存</el-button>
        </span>
      </template>
    </el-dialog>

    <!-- 分配权限对话框 -->
    <el-dialog v-model="permissionDialogVisible" title="分配权限" width="800px">
      <div class="permission-tree">
        <el-tree
          ref="permissionTreeRef"
          :data="permissionTree"
          :props="permissionProps"
          show-checkbox
          node-key="id"
          default-expand-all
        />
      </div>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="permissionDialogVisible = false">取消</el-button>
          <el-button type="primary" @click="savePermissions">保存权限</el-button>
        </span>
      </template>
    </el-dialog>

    <!-- 查看用户对话框 -->
    <el-dialog v-model="userDialogVisible" title="角色用户列表" width="800px">
      <el-table :data="roleUsers" style="width: 100%">
        <el-table-column prop="username" label="用户名" width="150" />
        <el-table-column prop="realName" label="真实姓名" width="150" />
        <el-table-column prop="email" label="邮箱" width="200" />
        <el-table-column prop="status" label="状态" width="100">
          <template #default="scope">
            <el-tag :type="scope.row.status === 'active' ? 'success' : 'danger'">
              {{ scope.row.status === 'active' ? '启用' : '禁用' }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="lastLoginTime" label="最后登录" width="160">
          <template #default="scope">
            {{ formatDateTime(scope.row.lastLoginTime) }}
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>
  </div>
</template>

<script setup>
import { ref, computed, onMounted } from 'vue';
import { useRouter } from 'vue-router';
import { ElMessage, ElMessageBox } from 'element-plus';
import { Search, Refresh, Plus } from '@element-plus/icons-vue';
import SidebarMenu from './SidebarMenu.vue';
import Navbar from './CommonNavbar.vue';
import api from '../utils/request.js';

const router = useRouter();
const activeMenu = ref('2-1'); // 角色管理菜单项
const loading = ref(false);
const roleDialogVisible = ref(false);
const permissionDialogVisible = ref(false);
const userDialogVisible = ref(false);
const selectedRole = ref({});
const selectedRows = ref([]);
const roleFormRef = ref();
const permissionTreeRef = ref();

const currentAvatar = ref('https://i.gtimg.cn/club/item/face/img/2/15922_100.gif');

// 查询表单
const queryForm = ref({
  roleName: '',
  roleDescription: '',
  status: ''
});

// 分页
const pagination = ref({
  currentPage: 1,
  pageSize: 20,
  total: 0
});

// 统计信息
const statistics = ref({
  totalRoles: 0,
  activeRoles: 0,
  totalUsers: 0,
  totalPermissions: 0
});

// 角色表单
const roleForm = ref({
  name: '',
  description: '',
  status: 'active',
  sortWeight: 0
});

// 表单验证规则
const roleRules = {
  name: [
    { required: true, message: '请输入角色名称', trigger: 'blur' },
    { min: 2, max: 20, message: '角色名称长度在 2 到 20 个字符', trigger: 'blur' }
  ],
  description: [
    { required: true, message: '请输入角色描述', trigger: 'blur' },
    { max: 200, message: '角色描述不能超过 200 个字符', trigger: 'blur' }
  ]
};

// 权限树配置
const permissionProps = {
  children: 'children',
  label: 'name'
};

// 权限树数据
const permissionTree = ref([
  {
    id: 1,
    name: '用户管理',
    children: [
      { id: 11, name: '查看用户' },
      { id: 12, name: '创建用户' },
      { id: 13, name: '编辑用户' },
      { id: 14, name: '删除用户' }
    ]
  },
  {
    id: 2,
    name: '角色管理',
    children: [
      { id: 21, name: '查看角色' },
      { id: 22, name: '创建角色' },
      { id: 23, name: '编辑角色' },
      { id: 24, name: '删除角色' }
    ]
  },
  {
    id: 3,
    name: '权限管理',
    children: [
      { id: 31, name: '查看权限' },
      { id: 32, name: '分配权限' }
    ]
  },
  {
    id: 4,
    name: '系统管理',
    children: [
      { id: 41, name: '系统设置' },
      { id: 42, name: '日志查看' }
    ]
  }
]);

// 角色用户数据
const roleUsers = ref([
  {
    username: 'admin',
    realName: '系统管理员',
    email: 'admin@example.com',
    status: 'active',
    lastLoginTime: '2024-01-15 10:30:00'
  },
  {
    username: 'zhangsan',
    realName: '张三',
    email: 'zhangsan@example.com',
    status: 'active',
    lastLoginTime: '2024-01-15 09:15:00'
  }
]);

// 角色数据
const roles = ref([]);

// 计算属性
const dialogTitle = computed(() => {
  return roleForm.value.id ? '编辑角色' : '新增角色';
});

// 导航方法
const goToRoleManagement = () => router.push('/RoleManagement');
const goToMenuManagement = () => router.push('/MenuManagement');
const goToPermissionControl = () => router.push('/PermissionControl');
const goToSystemSetting = () => router.push('/system');
const goToLogManagement = () => router.push('/LogManagement');
const goToFileManagement = () => router.push('/FileManagement');
const goToArticleManagement = () => router.push('/ArticleManagement');
const goToUserInfoManagement = () => router.push('/UserInfoManagement');

// 获取角色列表
const fetchRoles = async () => {
  try {
    loading.value = true;
    
    // 构建查询参数
    const params = {
      pageIndex: pagination.value.currentPage,
      pageSize: pagination.value.pageSize
    };
    
    // 添加查询条件
    if (queryForm.value.roleName) {
      params.name = queryForm.value.roleName;
    }
    
    console.log('查询参数:', params);
    
    const response = await api.get('/api/roles', { params });
    
    console.log('获取角色列表响应:', response);
    
    if (response.data.success) {
      const data = response.data.data;
      
      console.log('角色数据:', data);
      
      // 更新角色列表
      roles.value = data.roles.map(role => ({
        id: role.id,
        name: role.name,
        description: role.description,
        status: 'active', // 后端没有状态字段，默认为启用
        userCount: role.userCount || 0,
        permissionCount: role.menus ? role.menus.length : 0,
        createTime: role.createdAt,
        modifyTime: role.updatedAt,
        isSystem: role.name === '超级管理员' || role.name === 'SuperAdmin',
        sortWeight: 0
      }));
      
      console.log('处理后的角色列表:', roles.value);
      
      // 更新分页信息
      pagination.value.total = data.totalCount || 0;
      pagination.value.currentPage = data.pageIndex || 1;
      pagination.value.pageSize = data.pageSize || 10;
      
      // 更新统计信息
      updateStatistics();
      
      ElMessage.success('获取角色列表成功');
    } else {
      ElMessage.error(response.data.message || '获取角色列表失败');
    }
  } catch (error) {
    console.error('获取角色列表失败:', error);
    if (error.response?.status === 401) {
      ElMessage.error('登录已过期，请重新登录');
      router.push('/login');
    } else {
      ElMessage.error('获取角色列表失败，请检查网络连接');
    }
  } finally {
    loading.value = false;
  }
};

// 更新统计信息
const updateStatistics = () => {
  statistics.value.totalRoles = roles.value.length;
  statistics.value.activeRoles = roles.value.filter(role => role.status === 'active').length;
  statistics.value.totalUsers = roles.value.reduce((sum, role) => sum + role.userCount, 0);
  statistics.value.totalPermissions = roles.value.reduce((sum, role) => sum + role.permissionCount, 0);
};

// 查询方法
const searchRoles = () => {
  pagination.value.currentPage = 1; // 重置到第一页
  fetchRoles();
};

// 重置查询表单
const resetQueryForm = () => {
  queryForm.value = {
    roleName: '',
    roleDescription: '',
    status: ''
  };
  pagination.value.currentPage = 1;
  fetchRoles();
};

// 显示新增对话框
const showCreateDialog = () => {
  roleForm.value = {
    name: '',
    description: '',
    status: 'active',
    sortWeight: 0
  };
  roleDialogVisible.value = true;
};

// 编辑角色
const editRole = (role) => {
  roleForm.value = { ...role };
  roleDialogVisible.value = true;
};

// 保存角色
const saveRole = async () => {
  try {
    await roleFormRef.value.validate();
    
    loading.value = true;
    
    if (roleForm.value.id) {
      // 更新角色
      const updateData = {
        id: roleForm.value.id,
        name: roleForm.value.name,
        description: roleForm.value.description,
        menuIds: []
      };
      
      const response = await api.put('/api/roles', updateData);
      
      if (response.data.success) {
        ElMessage.success('角色更新成功');
        roleDialogVisible.value = false;
        fetchRoles(); // 重新获取列表
      } else {
        ElMessage.error(response.data.message || '角色更新失败');
      }
    } else {
      // 新增角色
      const createData = {
        name: roleForm.value.name,
        description: roleForm.value.description,
        menuIds: []
      };
      
      const response = await api.post('/api/roles', createData);
      
      if (response.data.success) {
        ElMessage.success('角色创建成功');
        roleDialogVisible.value = false;
        fetchRoles(); // 重新获取列表
      } else {
        ElMessage.error(response.data.message || '角色创建失败');
      }
    }
  } catch (error) {
    console.error('保存角色失败:', error);
    if (error.response?.data?.message) {
      ElMessage.error(error.response.data.message);
    } else {
      ElMessage.error('保存失败，请检查输入信息');
    }
  } finally {
    loading.value = false;
  }
};

// 分配权限
const assignPermissions = (role) => {
  selectedRole.value = role;
  permissionDialogVisible.value = true;
  // 模拟加载角色已有权限
  setTimeout(() => {
    permissionTreeRef.value.setCheckedKeys([11, 21, 31]);
  }, 100);
};

// 保存权限
const savePermissions = () => {
  const checkedKeys = permissionTreeRef.value.getCheckedKeys();
  const halfCheckedKeys = permissionTreeRef.value.getHalfCheckedKeys();
  console.log('选中的权限:', checkedKeys);
  console.log('半选中的权限:', halfCheckedKeys);
  ElMessage.success('权限分配成功');
  permissionDialogVisible.value = false;
};

// 查看用户
const viewUsers = (role) => {
  selectedRole.value = role;
  userDialogVisible.value = true;
};

// 切换状态
const toggleStatus = (role) => {
  const action = role.status === 'active' ? '禁用' : '启用';
  ElMessageBox.confirm(`确定要${action}角色"${role.name}"吗？`, `${action}确认`, {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning'
  }).then(() => {
    role.status = role.status === 'active' ? 'inactive' : 'active';
    ElMessage.success(`${action}成功`);
  }).catch(() => {
    ElMessage.info('已取消操作');
  });
};

// 删除角色
const deleteRole = (role) => {
  ElMessageBox.confirm(`确定要删除角色"${role.name}"吗？此操作不可恢复！`, '删除确认', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'error'
  }).then(async () => {
    try {
      loading.value = true;
      
      console.log('开始删除角色:', {
        id: role.id,
        name: role.name,
        url: `/api/roles/${role.id}`
      });
      
      const response = await api.delete(`/api/roles/${role.id}`);
      
      console.log('删除响应:', response);
      
      if (response.data.success) {
        ElMessage.success('删除成功');
        console.log('删除成功，重新获取角色列表');
        
        // 等待一下再重新获取列表，确保后端处理完成
        setTimeout(async () => {
          await fetchRoles();
        }, 500);
      } else {
        console.error('删除失败:', response.data);
        ElMessage.error(response.data.message || '删除失败');
      }
    } catch (error) {
      console.error('删除角色失败:', error);
      console.error('错误详情:', {
        status: error.response?.status,
        statusText: error.response?.statusText,
        data: error.response?.data,
        message: error.message
      });
      
      if (error.response?.data?.message) {
        ElMessage.error(error.response.data.message);
      } else if (error.response?.status === 400) {
        ElMessage.error('该角色正在被用户使用，无法删除');
      } else if (error.response?.status === 404) {
        ElMessage.error('角色不存在');
      } else if (error.response?.status === 500) {
        ElMessage.error('服务器内部错误，请稍后重试');
      } else {
        ElMessage.error('删除失败，请重试');
      }
    } finally {
      loading.value = false;
    }
  }).catch(() => {
    ElMessage.info('已取消删除');
  });
};

// 批量操作
const handleSelectionChange = (rows) => {
  selectedRows.value = rows;
};

const batchDisable = () => {
  if (selectedRows.value.length === 0) {
    ElMessage.warning('请选择要禁用的角色');
    return;
  }
  ElMessageBox.confirm(`确定要禁用选中的${selectedRows.value.length}个角色吗？`, '批量禁用确认', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning'
  }).then(() => {
    selectedRows.value.forEach(role => {
      if (!role.isSystem) {
        role.status = 'inactive';
      }
    });
    ElMessage.success('批量禁用成功');
  });
};

const batchDelete = () => {
  if (selectedRows.value.length === 0) {
    ElMessage.warning('请选择要删除的角色');
    return;
  }
  ElMessageBox.confirm(`确定要删除选中的${selectedRows.value.length}个角色吗？此操作不可恢复！`, '批量删除确认', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'error'
  }).then(async () => {
    try {
      loading.value = true;
      
      // 批量删除选中的角色
      const deletePromises = selectedRows.value
        .filter(role => !role.isSystem)
        .map(async (role) => {
          try {
            console.log('删除角色:', role.name, role.id);
            const response = await api.delete(`/api/roles/${role.id}`);
            return { success: true, role, response };
          } catch (error) {
            console.error(`删除角色 ${role.name} 失败:`, error);
            return { success: false, role, error };
          }
        });
      
      const results = await Promise.all(deletePromises);
      
      const successCount = results.filter(r => r.success).length;
      const failCount = results.length - successCount;
      
      if (failCount === 0) {
        ElMessage.success('批量删除成功');
      } else {
        ElMessage.warning(`批量删除完成：成功 ${successCount} 个，失败 ${failCount} 个`);
      }
      
      fetchRoles(); // 重新获取列表
    } catch (error) {
      console.error('批量删除失败:', error);
      ElMessage.error('批量删除失败，请重试');
    } finally {
      loading.value = false;
    }
  });
};

// 分页处理
const handleSizeChange = (size) => {
  pagination.value.pageSize = size;
  pagination.value.currentPage = 1;
  fetchRoles();
};

const handleCurrentChange = (page) => {
  pagination.value.currentPage = page;
  fetchRoles();
};

// 格式化方法
const formatDateTime = (dateTime) => {
  if (!dateTime) return '';
  return new Date(dateTime).toLocaleString('zh-CN');
};

// 组件挂载时加载数据
onMounted(() => {
  fetchRoles();
});
</script>

<style scoped>
.query-card {
  margin-bottom: 20px;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(80, 120, 200, 0.08);
}

.statistics-row {
  margin-bottom: 20px;
}

.statistics-card {
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(80, 120, 200, 0.08);
  transition: transform 0.2s, box-shadow 0.2s;
}

.statistics-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(80, 120, 200, 0.12);
}

.statistics-item {
  text-align: center;
  padding: 20px 0;
}

.statistics-number {
  font-size: 28px;
  font-weight: bold;
  color: #4f46e5;
  margin-bottom: 8px;
}

.statistics-label {
  font-size: 14px;
  color: #666;
}

.role-table-card {
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(80, 120, 200, 0.08);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-header span {
  font-size: 18px;
  font-weight: bold;
  color: #4f46e5;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.role-name {
  display: flex;
  align-items: center;
  gap: 8px;
}

.system-badge {
  background: #ff6b6b;
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}


.el-table {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(80, 120, 200, 0.08);
  background: #fff;
}

.el-table th {
  background: #e0e7ff !important;
  color: #4f46e5;
  font-weight: 600;
  font-size: 15px;
}

.el-table tr {
  transition: background 0.2s;
}

.el-table tr:hover > td {
  background: #f1f5ff !important;
}

.el-table .el-button[type="text"] {
  color: #6366f1;
  font-weight: 500;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
}

.el-table .el-button[type="text"]:hover {
  background: #e0e7ff;
  color: #3b3b3b;
}

.el-table .el-button[type="text"]:disabled {
  color: #c0c4cc;
  cursor: not-allowed;
}

.pagination-container {
  display: flex;
  justify-content: center;
  margin-top: 20px;
  padding: 20px 0;
}

.permission-tree {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid #e0e7ef;
  border-radius: 8px;
  padding: 16px;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.el-form-item {
  margin-bottom: 16px;
}

.el-button {
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.2s;
}

.el-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.el-card {
  border: none;
  transition: all 0.3s;
}

.el-card:hover {
  box-shadow: 0 4px 20px rgba(80, 120, 200, 0.12);
}

.el-tag {
  border-radius: 6px;
  font-weight: 500;
}

.el-select {
  width: 180px;
}

.el-input {
  width: 180px;
}

.el-input[type="textarea"] {
  width: 100%;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .el-form--inline .el-form-item {
    display: block;
    margin-bottom: 10px;
  }
  
  .el-input,
  .el-select {
    width: 100%;
  }
  
  .header-actions {
    flex-direction: column;
    gap: 5px;
  }
}
</style>

